/*
 * DTOEvent.cpp
 *
 *  Created on: Oct 13, 2011
 *      Author: gonzalo
 */

#include "DTOEvent.h"

DTOEvent::DTOEvent(int keyUnicode,
		int type,
		int h,
		int w,
		int x,
		int y,
		int code,
		int buttonState,
		int key,
		std::string owner) : DTO(EVENT,owner){
	this->keyUnicode = keyUnicode;
	this->type = type;
	this->h = h;
	this->w = w;
	this->x = x;
	this->y = y;
	this->code = code;
	this->buttonState =buttonState;
	this->key = key;
}
DTOEvent::DTOEvent(std::string& aDeserealizar,std::string owner) : DTO(EVENT,owner){
	deserializar(aDeserealizar);
}

std::string DTOEvent::serializar(){
	std::stringstream retorno;

	retorno << UtilString::TOlenghtStringStringValue(keyUnicode);
	retorno << UtilString::TOlenghtStringStringValue(type);
	retorno << UtilString::TOlenghtStringStringValue(h);
	retorno << UtilString::TOlenghtStringStringValue(w);
	retorno << UtilString::TOlenghtStringStringValue(x);
	retorno << UtilString::TOlenghtStringStringValue(y);
	retorno << UtilString::TOlenghtStringStringValue(code);
	retorno << UtilString::TOlenghtStringStringValue(buttonState);
	retorno << UtilString::TOlenghtStringStringValue(key);

	return retorno.str();
}

void DTOEvent::deserializar(std::string& string){
	keyUnicode = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	type = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	h = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	w = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	x = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	y = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	code = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	buttonState = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	key = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
}

DTOEvent::~DTOEvent() {
	// TODO Auto-generated destructor stub
}


